﻿using System;
using System.Collections.Generic;
using System.Data.SQLite;
using System.Linq;
using System.Text;
using _4m.models;
using _4m.utils;

namespace _4m.services
{
    public class OnRangeDao
    {
        private string connStr;

        public OnRangeDao(string connStr)
        {
            this.connStr = connStr;
        }

        public int CreateNewRecord(OnRangeTable onRangeTable)
        {
            int count = 0;
            var parameters = new SQLiteParameter[]
                                            {
                                                new SQLiteParameter("@year", onRangeTable.Year),
                                                new SQLiteParameter("@month", onRangeTable.Month), 
                                                new SQLiteParameter("@range_name", onRangeTable.RangeName), 
                                                new SQLiteParameter("@range_type", onRangeTable.RangeType),
                                                new SQLiteParameter("@sickness_num", onRangeTable.SicknessNum),
                                                new SQLiteParameter("@dead_num", onRangeTable.DeadNum),
                                            };
            var sqLiteUtils = new SQLiteUtils();
            count = sqLiteUtils.ExecuteUpdate(SQLConstants.InsertTableOnRange, parameters, this.connStr);
            return count;
        }
    }
}
